function t(a) {
    o.showLoading("正在加载数据"), wx.request({
        url: i.globalData.host + "/lotto/v2/list",
        method: "GET",
        dataType: "json",
        data: {
            access_token: o.getStorage("accessToken"),
            type: 0,
            page: a.data.page,
            count: 10
        },
        success: function(e) {
            if (o.hideLoading(), -500 != e.data.sta) if (0 == e.data.sta) {
                var i = e.data.data, s = a.data.page, n = !1;
                10 == i.length && (n = !0);
                for (var d = 0; d < i.length; d++) 0 != i[d].date && (i[d].date = o.formatDate(1e3 * i[d].date, "MM/dd HH:mm"));
                console.log(i), a.setData({
                    lottoList: 1 == s ? i : a.data.lottoList.concat(i),
                    page: s + 1,
                    moreData: n
                });
            } else o.showFailedToast("数据加载失败", e.data.msg); else o.login(a, function() {
                t(a);
            });
        },
        fail: function(t) {
            console.log(t);
        }
    });
}

function a(e) {
    o.showLoading("正在删除");
    var s = e.data.index, n = e.data.lottoList, d = n[s].lid;
    wx.request({
        url: i.globalData.host + "/lotto/v1/remove",
        data: {
            access_token: wx.getStorageSync("accessToken"),
            lid: d
        },
        method: "POST",
        success: function(i) {
            o.hideLoading(), -500 != i.data.sta ? 0 == i.data.sta ? (o.showToast("删除成功"), e.setData({
                lottoList: n,
                confirmDialog: !1,
                page: 1
            }), t(e)) : o.showFailedToast("删除失败", i.data.msg) : o.login(function() {
                a(e);
            });
        },
        fail: function(t) {
            o.hideLoading(), o.showFailedToast("删除失败");
        }
    });
}

var o = require("../../utils/util.js"), e = require("../../tmp/tmp.js"), i = getApp();

Page({
    data: {
        lottoList: null,
        page: 1,
        moreData: !1,
        confirmDialog: !1
    },
    onLoad: function(t) {
        e.enRoll(this);
    },
    onShow: function() {
        this.setData({
            toDetail: !1,
            page: 1
        }), t(this);
    },
    onReachBottom: function() {
        this.data.moreData && t(this);
    },
    inputChange: function(t) {
        var a = t.detail.value, o = !1;
        a.length > 3 && a != this.data.code && (o = !0), this.setData({
            inputCode: a,
            deleteTips: o
        });
    },
    deleteLotto: function(t) {
        this.setData({
            confirmDialog: !0,
            deleteTips: !1,
            code: Math.random().toString().substring(2, 6)
        });
    },
    deleteSubmit: function(t) {
        var o = !1;
        this.data.inputCode != this.data.code ? (o = !0, this.setData({
            deleteTips: o
        })) : (console.log("confirm delete"), a(this, this.data.cid));
    },
    closeConfirmDialog: function() {
        this.setData({
            confirmDialog: !1
        });
    }
});